package com.fx.dao.impl;

import com.fx.dao.BaseDao;
import com.fx.dao.IotBeanDao;
import com.fx.pojo.IotBean;

import java.util.List;

/**
 * @author: 梁峰源
 * @date: 2021/10/7 16:09
 * Description:
 */
public class IotBeanDaoImpl extends BaseDao implements IotBeanDao {
    @Override
    public int SaveIotBean(IotBean iotBean) {
        String sql="INSERT INTO practice1001(`QuerySensorType`,`QueryStartTime`,`illumination`,`temperature`,`humidity`)\n" +
                "VALUES(?,?,?,?,?);";
        return update(sql, iotBean.getQuerySensorType(),iotBean.getQueryStartTime(),
                iotBean.getIllumination(),iotBean.getTemperature(),iotBean.getHumidity());
    }

    @Override
    public IotBean queryIotBeanByStartTime(String QueryStartTime) {
        String sql="SELECT `id`,`QuerySensorType`,`QueryStartTime`,`illumination`,`temperature`,`humidity` from practice1001\n" +
                "WHERE QueryStartTime= ? ;";
        return queryForone(IotBean.class, sql, QueryStartTime);
    }

    @Override
    public List<IotBean> queryAll() {
        String sql="SELECT `id`,`QuerySensorType`,`QueryStartTime`,`illumination`,`temperature`,`humidity` from practice1001;";
        return queryForList(IotBean.class,sql);
    }
}
